# Contributor: Antoine Fontaine <antoine.fontaine@epfl.ch>
# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=pantalaimon
pkgver=0.10.5
pkgrel=4
pkgdesc="E2EE-aware Matrix proxy daemon"
options="!check" # Tests hang
url="https://github.com/matrix-org/pantalaimon"
arch="noarch"
license="Apache-2.0"
depends="
	py3-aiohttp
	py3-appdirs
	py3-atomicwrites
	py3-attrs
	py3-cachetools
	py3-click
	py3-janus
	py3-keyring
	py3-logbook
	py3-matrix-nio
	py3-olm
	py3-peewee
	py3-prompt_toolkit
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-aioresponses
	py3-faker
	py3-hpack
	py3-hyperframe
	py3-pytest
	py3-pytest-aiohttp
	"
subpackages="
	$pkgname-ui
	$pkgname-doc
	$pkgname-pyc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/matrix-org/pantalaimon/archive/$pkgver.tar.gz
	fix-typo.patch
	fix-media.patch
	fix-tox.patch
	fix-presence.patch
	"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	install -Dm644 docs/man/panctl.1 -t "$pkgdir"/usr/share/man/man1/
	install -Dm644 docs/man/pantalaimon.5 -t "$pkgdir"/usr/share/man/man5/
	install -Dm644 docs/man/pantalaimon.8 -t "$pkgdir"/usr/share/man/man8/
}

ui() {
	depends="
		$pkgname=$pkgver-r$pkgrel
		py3-gobject3
		py3-dbus
		py3-pydbus
		py3-notify2
		"

	amove usr/bin/panctl
}

sha512sums="
8648037b49aeae9cdc10eaa83257412335267e70163d8800979a47b3c4bfa88d03a5a62272bddfdf1a77b8ea781b089512b6edae0f8ec67a36b28c1098f1d36e  pantalaimon-0.10.5.tar.gz
08b8d353ce496cfc893efde3e80ad9847730b6105926f2d2146c1f1e93af451f7ec138d57f1da48711962f6a9687ce061187fe5ec7e9cc6ffdf6a1a711fca924  fix-typo.patch
8305b04edb607549332d77e54eda88e93e61ba4e209622ba2b55ce3de37d112f3f054b596181c39bdb9f9f0464b87658364ca06bfa69bd8a518c01a07af1a423  fix-media.patch
6b8b9c87f261dcd78e8b3bf07d417e831d816077eb78f21499ee2847dea05aaef007a5dde77fb18904ceba35d82f02bb2afc89c1c04e3e6a3b76697bbf70da7e  fix-tox.patch
2660521a127059ae53fc962609a5f6df90f024723638ea0c148e434227f8d41fca6d18221fbdc78e990c8aa9192ac85746446cdac8ae6a5243e4864bb2c8a4b2  fix-presence.patch
"
